/**
 * Created by zf233 on 2020/2/10
 */
 var remove_share_function;
 var copy_share_url_function;
 $(function () {
     function isEmpty(obj) {
         if (typeof obj == "undefined" || obj == null || obj == "") {
             return true;
         } else {
             return false;
         }
     }
     var getCurrentUser = function () {
         $.ajax({
             async: true,
             url: "/user/current/user/get",
             dataType: "json",
             success: function (data) {
                 if (data.status == 200) {
                     $("#user_head").attr("src", data.data.headUrl).load();
                     var title_username = !isEmpty(data.data.nickname) ? data.data.nickname : !isEmpty(data.data.username) ? data.data.username : "未设置";
                     $("#title_username").text(title_username);
                     $("#username_input").val(data.data.username);
                     $("#nickname_input").val(data.data.nickname);
                     $("#user_classify_span").text(data.data.role);
                     $("#user_classify_input").val(data.data.role);
                     $("#level_input").val(data.data.level);
                     $("#growthValue_input").val(data.data.growthValue);
                     $("#createTime_iput").val(data.data.createTime);
                     $("#email_input").val(data.data.email);
                     $("#phone_input").val(data.data.phone);
                     $("#question_input").val(data.data.question);
                     $("#answer_input").val(data.data.answer);
                     $("#invite_code_input").val(data.data.inviteCode);
                     $("#assist_other").val(data.data.assistCode);
                     if (isEmpty(data.data.assistCode)) {
                         $("#assist_dialog").show();
                     } else {
                         $("#assist_dialog").hide();
                     }
                     if (!isEmpty(data.data.email)) {
                         $("#unbindEmail").show();
                         $("#bindEmail").hide();
                     } else {
                         $("#unbindEmail").hide();
                         $("#bindEmail").show();
                     }
                     if (!isEmpty(data.data.phone)) {
                         $("#unbindPhone").show();
                         $("#bindPhone").hide();
                     } else {
                         $("#unbindPhone").hide();
                         $("#bindPhone").show();
                     }
                     var capacityTest = data.data.useCapacity + " / " + data.data.capacity
                     $("#capacity_span_in").text(capacityTest);
                     $("#availableDownloadCapacity_span").text(data.data.availableDownloadCapacity)
                     $("#freeShareCount_span").text(data.data.freeShareCount)
                 } else {
                     toastr.options = {
                         "positionClass": "toast-top-title-center",
                     };
                     toastr.error(data.msg);
                 }
             },
             error: function (data) {
                 toastr.options = {
                     "positionClass": "toast-top-title-center",
                 };
                 toastr.error("获取用户信息失败");
             },
             type: "post"
         });
     }
     getCurrentUser();
 
     var click_a_array = [
         $("#user_a"),
         $("#account_a"),
         $("#capacity_a"),
         $("#pay_a"),
         $("#merge_a"),
         $("#message_a")
     ];
     var show_div_array = [
         $("#user_div"),
         $("#account_div"),
         $("#capacity_div"),
         $("#pay_div"),
         $("#merge_div"),
         $("#message_div")
     ];
 
     function show_div(index) {
         for (var i = 0; i < show_div_array.length; i++) {
             if (i == index) {
                 $(show_div_array[i]).show();
             } else {
                 $(show_div_array[i]).hide();
             }
         }
     }
 
     for (var i = 0; i < click_a_array.length; i++) {
         $(click_a_array[i]).click(function () {
             for (var j = 0; j < click_a_array.length; j++) {
                 if ($(this).attr("id") == $(click_a_array[j]).attr("id")) {
                     show_div(j);
                     $(this).css("background-color", "rgb(245, 245, 245)");
                 } else {
                     $(click_a_array[j]).css("background-color", "");
                 }
             }
         });
     }
 
     $("#user_a").click();
 
     copy_share_url_function = function (el) {
         var url = $(el).attr("url");
         alert(url);
     }
 
     $("#user_head").mouseover(function () {
         var top = $("#user_head").offset().top + $("#user_head").height();
         var left = $("#user_head").offset().left + $("#user_head").width() + 10;
         $("#move_show_span").css("top", top + 'px');
         $("#move_show_span").css("left", left + 'px');
         $("#move_show_span").text("点击以设置新的头像");
         $("#move_show_span").show();
     })
     $("#user_head").mouseout(function () {
         $("#move_show_span").hide();
     })
 
     $("#growth_span").mouseover(function () {
         var top = $("#growth_span").offset().top + $("#growth_span").height();
         var left = $("#growth_span").offset().left + $("#growth_span").width() + 10;
         $("#move_show_span").css("top", top + 'px');
         $("#move_show_span").css("left", left + 'px');
         $("#move_show_span").text("成长值决定了您的等级");
         $("#move_show_span").show();
     })
     $("#growth_span").mouseout(function () {
         $("#move_show_span").hide();
     })
 
     $("#create_span").mouseover(function () {
         var top = $("#create_span").offset().top + $("#create_span").height();
         var left = $("#create_span").offset().left + $("#create_span").width() + 10;
         $("#move_show_span").css("top", top + 'px');
         $("#move_show_span").css("left", left + 'px');
         $("#move_show_span").text("注册日期");
         $("#move_show_span").show();
     })
     $("#create_span").mouseout(function () {
         $("#move_show_span").hide();
     })
 
     $("#level_span").mouseover(function () {
         var top = $("#level_span").offset().top + $("#level_span").height();
         var left = $("#level_span").offset().left + $("#level_span").width() + 10;
         $("#move_show_span").css("top", top + 'px');
         $("#move_show_span").css("left", left + 'px');
         $("#move_show_span").text("用户等级决定了用户的存储容量、日免费下载额等");
         $("#move_show_span").show();
     })
     $("#level_span").mouseout(function () {
         $("#move_show_span").hide();
     })
 
     $("#classify_span").mouseover(function () {
         var top = $("#classify_span").offset().top + $("#classify_span").height();
         var left = $("#classify_span").offset().left + $("#classify_span").width() + 10;
         $("#move_show_span").css("top", top + 'px');
         $("#move_show_span").css("left", left + 'px');
         $("#move_show_span").text("用户类型体现了用户的注册方式，所拥有的信息修改权限也不同");
         $("#move_show_span").show();
     })
     $("#classify_span").mouseout(function () {
         $("#move_show_span").hide();
     })
 
     $("#username_span").mouseover(function () {
         var top = $("#username_span").offset().top + $("#username_span").height();
         var left = $("#username_span").offset().left + $("#username_span").width() + 10;
         $("#move_show_span").css("top", top + 'px');
         $("#move_show_span").css("left", left + 'px');
         var classify = $("#user_classify_span").text().replace(/\s+/g, "");;
         if (classify == 'QQ') {
             $("#move_show_span").text("用户名是您在XCloud的唯一标示。鉴于您是QQ用户，可以设置一次且设置后不可更改,如已设置请忽略");
         } else {
             $("#move_show_span").text("用户名是您在XCloud的唯一标示，不可更改");
         }
         $("#move_show_span").show();
     })
     $("#username_span").mouseout(function () {
         $("#move_show_span").hide();
     })
 
     $("#invite_code_span").mouseover(function () {
         var top = $("#invite_code_span").offset().top + $("#invite_code_span").height();
         var left = $("#invite_code_span").offset().left + $("#invite_code_span").width() + 10;
         $("#move_show_span").css("top", top + 'px');
         $("#move_show_span").css("left", left + 'px');
         $("#move_show_span").text("这是您的邀请码，你可以通过邀请他人注册获取奖励红包");
         $("#move_show_span").show();
     })
     $("#invite_code_span").mouseout(function () {
         $("#move_show_span").hide();
     })
 
     $("#assist_code_span").mouseover(function () {
         var top = $("#assist_code_span").offset().top + $("#assist_code_span").height();
         var left = $("#assist_code_span").offset().left + $("#assist_code_span").width() + 10;
         $("#move_show_span").css("top", top + 'px');
         $("#move_show_span").css("left", left + 'px');
         $("#move_show_span").text("您可以填写他人邀请码，以协助他人获取奖励红包，只可以邀请一次");
         $("#move_show_span").show();
     })
     $("#assist_code_span").mouseout(function () {
         $("#move_show_span").hide();
     })
 
     $("#nickname_span").mouseover(function () {
         var top = $("#nickname_span").offset().top + $("#nickname_span").height();
         var left = $("#nickname_span").offset().left + $("#nickname_span").width() + 10;
         $("#move_show_span").css("top", top + 'px');
         $("#move_show_span").css("left", left + 'px');
         $("#move_show_span").text("昵称是您的用户别名，当未设置昵称或昵称为空时默认展示您的用户名");
         $("#move_show_span").show();
     })
     $("#nickname_span").mouseout(function () {
         $("#move_show_span").hide();
     })
 
     $("#password_span").mouseover(function () {
         var top = $("#password_span").offset().top + $("#password_span").height();
         var left = $("#password_span").offset().left + $("#password_span").width() + 10;
         $("#move_show_span").css("top", top + 'px');
         $("#move_show_span").css("left", left + 'px');
         var classify = $("#user_classify_span").text().replace(/\s+/g, "");;
         if (classify == 'QQ') {
             $("#move_show_span").text("账号+密码的组合可以快速登陆XCloud。鉴于您是QQ用户，建议尽快设置账号和密码");
         } else {
             $("#move_show_span").text("账号+密码的组合可以快速登陆XCloud");
         }
         $("#move_show_span").show();
     })
     $("#password_span").mouseout(function () {
         $("#move_show_span").hide();
     })
 
     $("#email_span").mouseover(function () {
         var top = $("#email_span").offset().top + $("#email_span").height();
         var left = $("#email_span").offset().left + $("#email_span").width() + 10;
         $("#move_show_span").css("top", top + 'px');
         $("#move_show_span").css("left", left + 'px');
         var classify = $("#user_classify_span").text().replace(/\s+/g, "");;
         if (classify == 'QQ') {
             var email = $("#user_email_span").text().replace(/\s+/g, "");;
             if (isEmpty(email)) {
                 $("#move_show_span").text("邮箱+密码的组合可以快速登陆XCloud。鉴于您是QQ用户，建议您尽快绑定邮箱");
             } else {
                 $("#move_show_span").text("邮箱+密码的组合可以快速登陆XCloud。");
             }
         } else {
             $("#move_show_span").text("邮箱+密码的组合可以快速登陆XCloud，非QQ用户不可更改邮箱");
         }
         $("#move_show_span").show();
     })
     $("#email_span").mouseout(function () {
         $("#move_show_span").hide();
     })
 
     $("#question_span").mouseover(function () {
         var top = $("#question_span").offset().top + $("#question_span").height();
         var left = $("#question_span").offset().left + $("#question_span").width() + 10;
         $("#move_show_span").css("top", top + 'px');
         $("#move_show_span").css("left", left + 'px');
         $("#move_show_span").text("可以通过账号+问题+答案的组合找回你的密码，问题长度大于五");
         $("#move_show_span").show();
     })
     $("#question_span").mouseout(function () {
         $("#move_show_span").hide();
     })
 
     $("#answer_span").mouseover(function () {
         var top = $("#answer_span").offset().top + $("#answer_span").height();
         var left = $("#answer_span").offset().left + $("#answer_span").width() + 10;
         $("#move_show_span").css("top", top + 'px');
         $("#move_show_span").css("left", left + 'px');
         $("#move_show_span").text("可以通过账号+问题+答案的组合找回你的密码，答案长度大于五");
         $("#move_show_span").show();
     })
     $("#answer_span").mouseout(function () {
         $("#move_show_span").hide();
     })
 
     $("#capacity_span").mouseover(function () {
         var top = $("#capacity_span").offset().top + $("#capacity_span").height();
         var left = $("#capacity_span").offset().left + $("#capacity_span").width() + 10;
         $("#move_show_span").css("top", top + 'px');
         $("#move_show_span").css("left", left + 'px');
         $("#move_show_span").text("这是您XCloud已用/可用的容量信息");
         $("#move_show_span").show();
     })
     $("#capacity_span").mouseout(function () {
         $("#move_show_span").hide();
     })
 
     $("#download_span").mouseover(function () {
         var top = $("#download_span").offset().top + $("#download_span").height();
         var left = $("#download_span").offset().left + $("#download_span").width() + 10;
         $("#move_show_span").css("top", top + 'px');
         $("#move_show_span").css("left", left + 'px');
         $("#move_show_span").text("这是您的下载余量。下载余量包含结余、等级、打赏赠送三种流量，消耗顺序:结余->等级->打赏赠送。流量规则:结余流量不参与结余，打赏赠送流量有效期30天");
         $("#move_show_span").show();
     })
     $("#download_span").mouseout(function () {
         $("#move_show_span").hide();
     })
 
     $("#share_span").mouseover(function () {
         var top = $("#share_span").offset().top + $("#share_span").height();
         var left = $("#share_span").offset().left + $("#share_span").width() + 10;
         $("#move_show_span").css("top", top + 'px');
         $("#move_show_span").css("left", left + 'px');
         $("#move_show_span").text("这是您当日可免费分享文件二维码或链接的次数。请注意获取分享文件将减少您的下载余量");
         $("#move_show_span").show();
     })
     $("#share_span").mouseout(function () {
         $("#move_show_span").hide();
     })
 
     $("#merge_span").mouseover(function () {
         var top = $("#merge_span").offset().top + $("#merge_span").height();
         var left = $("#merge_span").offset().left + $("#merge_span").width() + 10;
         $("#move_show_span").css("top", top + 'px');
         $("#move_show_span").css("left", left + 'px');
         $("#move_show_span").text("正确填写合并邮箱和密码可以将目标账户与当前账户合并");
         $("#move_show_span").show();
     })
     $("#merge_span").mouseout(function () {
         $("#move_show_span").hide();
     })
 
 
     $("#user_head").click(function () {
         $("#update_user_head").click();
     })
 
     $("#update_user_head").change(function () {
         upload();
     });
 
     function upload() {
         if ($("#update_user_head").val() == '') {
             return;
         }
         var formData = new FormData();
         formData.append('headPhoto', document.getElementById('update_user_head').files[0]);
         $.ajax({
             async: true,
             url: "/file/update/head",
             data: formData,
             contentType: false,
             processData: false,
             dataType: "json",
             success: function (data) {
                 if (data.status == 200) {
                     toastr.options = {
                         "positionClass": "toast-top-title-center",
                     };
                     toastr.info("头像更新成功");
                     getCurrentUser();
                 } else {
                     toastr.options = {
                         "positionClass": "toast-top-title-center",
                     };
                     toastr.error(data.msg);
                 }
 
             },
             error: function (data) {
                 toastr.options = {
                     "positionClass": "toast-top-title-center",
                 };
                 toastr.error("更新失败");
             },
             type: "post"
         });
     }
 
     $("#modal_username_button").click(function () {
         var username = $("#username_input").val().replace(/\s+/g, "");;
         newUsername = $("#modal_username_input").val().replace(/\s+/g, "");;
         if (newUsername != username) {
             if (/^[a-zA-Z][a-zA-Z0-9_]{4,15}$/.test(newUsername) == false) {
                 toastr.options = {
                     "positionClass": "toast-top-title-center",
                 };
                 toastr.error("用户名格式有误！用户名格式：以字母开头的5位至16位字母数字下划线组合");
                 $("#username_input").val(username);
                 return false;
             }
             var flag = confirm("一经设置不可修改");
             if (flag) {
                 $.ajax({
                     async: true,
                     url: "/user/update",
                     data: {
                         updateFlag: 1,
                         username: newUsername
                     },
                     dataType: "json",
                     success: function (data) {
                         if (data.status == 200) {
                             toastr.options = {
                                 "positionClass": "toast-top-title-center",
                             };
                             toastr.info("修改成功");
                             getCurrentUser();
                         } else {
                             toastr.options = {
                                 "positionClass": "toast-top-title-center",
                             };
                             toastr.error(data.msg);
                         }
 
                     },
                     error: function (data) {
                         toastr.options = {
                             "positionClass": "toast-top-title-center",
                         };
                         toastr.error("修改失败");
                     },
                     type: "post"
                 });
             }
         }
     })
 
     $("#modal_nickname_button").click(function () {
         var nickname = $("#nickname_input").val().replace(/\s+/g, "");;
         newNickname = $("#modal_nickname_input").val().replace(/\s+/g, "");;
         if (newNickname != nickname) {
             if (!isEmpty(newNickname) && (newNickname.length > 16 || newNickname.length < 3)) {
                 toastr.options = {
                     "positionClass": "toast-top-title-center",
                 };
                 toastr.error("昵称格式有误！昵称格式：3位至16位字符");
                 return false;
             }
             $.ajax({
                 async: true,
                 url: "/user/update",
                 data: {
                     updateFlag: 2,
                     nickname: newNickname
                 },
                 dataType: "json",
                 success: function (data) {
                     if (data.status == 200) {
                         toastr.options = {
                             "positionClass": "toast-top-title-center",
                         };
                         toastr.info("修改成功");
                         getCurrentUser();
                     } else {
                         toastr.options = {
                             "positionClass": "toast-top-title-center",
                         };
                         toastr.error(data.msg);
                     }
 
                 },
                 error: function (data) {
                     toastr.options = {
                         "positionClass": "toast-top-title-center",
                     };
                     toastr.error("修改失败");
                 },
                 type: "post"
             });
         }
     })
 
     $("#modal_password_input_new_double").blur(function () {
         var double = $(this).val().replace(/\s+/g, "");;
         var newPassword = $("#modal_password_input_new").val().replace(/\s+/g, "");;
         if (newPassword != double) {
             toastr.options = {
                 "positionClass": "toast-top-title-center",
             };
             toastr.error("两次密码不一致");
         }
     })
 
     $("#modal_password_button").click(function () {
         var oldPassword = $("#modal_password_input").val().replace(/\s+/g, "");;
         var newPassword = $("#modal_password_input_new").val().replace(/\s+/g, "");;
         var newPasswordDouble = $("#modal_password_input_new_double").val().replace(/\s+/g, "");;
         if (!isEmpty(oldPassword) && /^[a-zA-Z]\w{4,15}$/.test(oldPassword) == false) {
             toastr.options = {
                 "positionClass": "toast-top-title-center",
             };
             toastr.error("旧密码格式有误:以字母开头的5位至16位字母数字下划线组合");
             return false;
         }
         if (newPassword != newPasswordDouble) {
             toastr.options = {
                 "positionClass": "toast-top-title-center",
             };
             toastr.error("两次密码不一致");
             return;
         }
         if (/^[a-zA-Z]\w{4,15}$/.test(newPassword) == false) {
             toastr.options = {
                 "positionClass": "toast-top-title-center",
             };
             toastr.error("新密码格式有误:以字母开头的5位至16位字母数字下划线组合");
             return false;
         }
         $.ajax({
             async: true,
             url: "/user/update",
             data: {
                 updateFlag: 3,
                 password: $.md5('zf233' + newPassword),
                 oldPassword: $.md5('zf233' + oldPassword)
             },
             dataType: "json",
             success: function (data) {
                 if (data.status == 200) {
                     toastr.options = {
                         "positionClass": "toast-top-title-center",
                     };
                     toastr.info("修改成功");
                 } else {
                     toastr.options = {
                         "positionClass": "toast-top-title-center",
                     };
                     toastr.error(data.msg);
                 }
             },
             error: function (data) {
                 toastr.options = {
                     "positionClass": "toast-top-title-center",
                 };
                 toastr.error("修改失败");
             },
             type: "post"
         });
     })
 
     $("#modal_email_button").click(function () {
         var email = $("#email_input").val().replace(/\s+/g, "");;
         var newEmail = $("#modal_email_input").val().replace(/\s+/g, "");;
         if (newEmail != email) {
             if (isEmpty(newEmail)) {
                 toastr.options = {
                     "positionClass": "toast-top-title-center",
                 };
                 toastr.error("邮箱不可为空");
                 return false;
             }
             if (/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(newEmail) == false) {
                 toastr.options = {
                     "positionClass": "toast-top-title-center",
                 };
                 toastr.error("邮箱格式有误");
                 return false;
             }
             newEmail = newEmail.replace(/www./, "");
             $.ajax({
                 async: true,
                 url: "/user/update",
                 data: {
                     updateFlag: 4,
                     email: newEmail
                 },
                 dataType: "json",
                 success: function (data) {
                     if (data.status == 200) {
                         toastr.options = {
                             "positionClass": "toast-top-title-center",
                         };
                         toastr.info(data.msg);
                         getCurrentUser();
                     } else {
                         toastr.options = {
                             "positionClass": "toast-top-title-center",
                         };
                         toastr.error(data.msg);
                     }
                 },
                 error: function (data) {
                     toastr.options = {
                         "positionClass": "toast-top-title-center",
                     };
                     toastr.error("修改失败");
                 },
                 type: "post"
             });
         }
     })
 
     $("#modal_phone_button").click(function () {
         var phone = $("#phone_input").val().replace(/\s+/g, "");;
         var newPhone = $("#modal_phone_input").val().replace(/\s+/g, "");;
         if (isEmpty(newPhone)) {
             toastr.options = {
                 "positionClass": "toast-top-title-center",
             };
             toastr.error("手机不可为空");
             return false;
         }
         if (phone != newPhone) {
             if (/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(newPhone) == false) {
                 toastr.options = {
                     "positionClass": "toast-top-title-center",
                 };
                 toastr.error("手机格式有误");
                 return false;
             }
             $.ajax({
                 async: true,
                 url: "/user/update",
                 data: {
                     updateFlag: 7,
                     phone: newPhone
                 },
                 dataType: "json",
                 success: function (data) {
                     if (data.status == 200) {
                         toastr.options = {
                             "positionClass": "toast-top-title-center",
                         };
                         toastr.info("修改成功");
                         getCurrentUser();
                     } else {
                         toastr.options = {
                             "positionClass": "toast-top-title-center",
                         };
                         toastr.error(data.msg);
                     }
 
                 },
                 error: function (data) {
                     toastr.options = {
                         "positionClass": "toast-top-title-center",
                     };
                     toastr.error("修改失败");
                 },
                 type: "post"
             });
         }
     })
 
     $("#unbindEmail").click(function () {
         $.ajax({
             async: true,
             url: "/user/update",
             data: {
                 updateFlag: 4,
                 email: ""
             },
             dataType: "json",
             success: function (data) {
                 if (data.status == 200) {
                     toastr.options = {
                         "positionClass": "toast-top-title-center",
                     };
                     toastr.info(data.msg);
                     getCurrentUser();
                 } else {
                     toastr.options = {
                         "positionClass": "toast-top-title-center",
                     };
                     toastr.error(data.msg);
                 }
             },
             error: function (data) {
                 toastr.options = {
                     "positionClass": "toast-top-title-center",
                 };
                 toastr.error("邮箱解绑失败");
             },
             type: "post"
         });
     })
 
     $("#unbindPhone").click(function () {
         $.ajax({
             async: true,
             url: "/user/update",
             data: {
                 updateFlag: 7,
                 phone: ""
             },
             dataType: "json",
             success: function (data) {
                 if (data.status == 200) {
                     toastr.options = {
                         "positionClass": "toast-top-title-center",
                     };
                     toastr.info(data.msg);
                     getCurrentUser();
                 } else {
                     toastr.options = {
                         "positionClass": "toast-top-title-center",
                     };
                     toastr.error(data.msg);
                 }
             },
             error: function (data) {
                 toastr.options = {
                     "positionClass": "toast-top-title-center",
                 };
                 toastr.error("手机解绑失败");
             },
             type: "post"
         });
     })
 
     $("#modal_answer_button").click(function () {
         var answer = $("#answer_input").val().replace(/\s+/g, "");;
         var newAnswer = $("#modal_answer_input").val().replace(/\s+/g, "");;
         if (newAnswer != answer) {
             if (newAnswer.length < 3 && !isEmpty(newAnswer) || newAnswer.length > 16) {
                 toastr.options = {
                     "positionClass": "toast-top-title-center",
                 };
                 toastr.error("找回密码答案格式有误！答案格式：5至16位字符");
                 return false;
             }
             $.ajax({
                 async: true,
                 url: "/user/update",
                 data: {
                     updateFlag: 6,
                     answer: newAnswer
                 },
                 dataType: "json",
                 success: function (data) {
                     if (data.status == 200) {
                         toastr.options = {
                             "positionClass": "toast-top-title-center",
                         };
                         toastr.info("修改成功");
                         getCurrentUser();
                     } else {
                         toastr.options = {
                             "positionClass": "toast-top-title-center",
                         };
                         toastr.error(data.msg);
                     }
 
                 },
                 error: function (data) {
                     toastr.options = {
                         "positionClass": "toast-top-title-center",
                     };
                     toastr.error("修改失败");
                 },
                 type: "post"
             });
         }
     })
 
     $("#merge_email_input").blur(function () {
         var email = $("#merge_email_input").val().replace(/\s+/g, "");;
         if (!isEmpty(email)) {
             if (/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(email) == false) {
                 toastr.options = {
                     "positionClass": "toast-top-title-center",
                 };
                 toastr.error("合并邮箱格式有误");
                 $("#merge_email_input").val("");
                 return false;
             }
         }
     })
 
     $("#merge_password_input").blur(function () {
         var password = $("#merge_password_input").val().replace(/\s+/g, "");;
         if (!isEmpty(password)) {
             if (/^[a-zA-Z]\w{4,15}$/.test(password) == false) {
                 toastr.options = {
                     "positionClass": "toast-top-title-center",
                 };
                 toastr.error("合并账号密码格式有误");
                 $("#merge_password_input").val("");
                 return false;
             }
         }
     })
 
     $("#merge_button").click(function () {
         var email = $("#email_input").val().replace(/\s+/g, "");;
         var merge_email = $("#merge_email_input").val().replace(/\s+/g, "");;
         if (isEmpty(merge_email)) {
             toastr.options = {
                 "positionClass": "toast-top-title-center",
             };
             toastr.error("合并账号邮箱不可以为空");
             return;
         }
         var password = $("#merge_password_input").val().replace(/\s+/g, "");;
         if (/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(merge_email) && /^[a-zA-Z]\w{4,15}$/.test(password) && email != merge_email) {
             var flag = confirm("确定要合并 " + merge_email + " 账户至当前账户吗? 请注意，被合并的目标账户的所有文件会统一迁移至当前账户的根目录下且保持目录结构。不可以合并当前用户，所填写的邮箱账户被合并后，其信息会被移除，您无法再使用被合并的邮箱账户进行登陆等操作！合并账户并不会提高您的等级，增加您的成长值、容量等相关信息！");
             if (!flag) {
                 return;
             }
             if (flag) {
                 if (!confirm("请谨慎合并，请再次确认！")) {
                     return;
                 }
             }
             $.ajax({
                 async: true,
                 url: "/user/merge",
                 data: {
                     email: merge_email,
                     password: $.md5('zf233' + password)
                 },
                 dataType: "json",
                 success: function (data) {
                     if (data.status == 200) {
                         toastr.options = {
                             "positionClass": "toast-top-title-center",
                         };
                         toastr.info("合并成功");
                         $("#merge_email_input").val("");
                         $("#merge_password_input").val("");
                     } else {
                         toastr.options = {
                             "positionClass": "toast-top-title-center",
                         };
                         toastr.error(data.msg);
                         $("#merge_email_input").val("");
                         $("#merge_password_input").val("");
                     }
                 },
                 error: function (data) {
                     toastr.options = {
                         "positionClass": "toast-top-title-center",
                     };
                     toastr.error("修改失败");
                     $("#merge_email_input").val("");
                     $("#merge_password_input").val("");
                 },
                 type: "post"
             });
         } else {
             if (email == merge_email) {
                 $("#merge_email_input").val("");
                 $("#merge_password_input").val("");
                 toastr.options = {
                     "positionClass": "toast-top-title-center",
                 };
                 toastr.error("不可以合并当前用户");
                 return;
             }
             $("#merge_email_input").val("");
             $("#merge_password_input").val("");
             toastr.options = {
                 "positionClass": "toast-top-title-center",
             };
             toastr.error("合并账户信息格式有误");
         }
     })
 
     $("#msg_button").click(function () {
         var phone = $("#msg_phone").val().replace(/\s+/g, "");;
         var msg = $("#msg_message").val().replace(/\s+/g, "");;
         if (isEmpty(phone) || isEmpty(msg)) {
             toastr.options = {
                 "positionClass": "toast-top-title-center",
             };
             toastr.error("请填写联系方式和反馈内容");
             return;
         }
         var flag = confirm("确定要提交反馈吗？");
         if (flag) {
             $.ajax({
                 async: true,
                 url: "/admin/feedback",
                 data: {
                     email: phone,
                     context: msg
                 },
                 dataType: "json",
                 success: function (data) {
                     if (data.status == 200) {
                         toastr.options = {
                             "positionClass": "toast-top-title-center",
                         };
                         toastr.info(data.msg);
                         $("#msg_phone").val("");
                         $("#msg_message").val("");
                     } else {
                         toastr.options = {
                             "positionClass": "toast-top-title-center",
                         };
                         toastr.error(data.msg);
                     }
                 },
                 error: function (data) {
                     toastr.options = {
                         "positionClass": "toast-top-title-center",
                     };
                     toastr.error("反馈发送失败");
                 },
                 type: "post"
             });
         }
     })
 
     $("#modal_assist_button").click(function () {
         var code = $("#modal_assist_input").val().replace(/\s+/g, "");;
         if (code.length != 16) {
             toastr.options = {
                 "positionClass": "toast-top-title-center",
             };
             toastr.error("邀请码格式有误");
             return;
         }
         $.ajax({
             async: true,
             url: "/user/assist",
             data: {
                 code: code
             },
             dataType: "json",
             success: function (data) {
                 if (data.status == 200) {
                     toastr.options = {
                         "positionClass": "toast-top-title-center",
                     };
                     toastr.info(data.msg);
                     getCurrentUser();
                 } else {
                     toastr.options = {
                         "positionClass": "toast-top-title-center",
                     };
                     toastr.error(data.msg);
                 }
             },
             error: function (data) {
                 toastr.options = {
                     "positionClass": "toast-top-title-center",
                 };
                 toastr.error("协助他人失败");
             },
             type: "post"
         });
     })
 
     var copyBtn = new ClipboardJS('.btn');
     copyBtn.on("success", function (e) {
         toastr.options = {
             "positionClass": "toast-top-title-center",
         };
         toastr.info("邀请码已复制至剪贴板");
         $("#share_link_input").blur();
     });
     copyBtn.on("error", function (e) {
         toastr.options = {
             "positionClass": "toast-top-title-center",
         };
         toastr.info("分享链接复制失败，请手动复制");
         $("#share_link_input").blur();
     });
     $("#share_link_input").focus(function () {
         if (!isEmpty($(this).val().replace(/\s+/g, ""))) {
             $("#copy_content").click();
         }
     });
 
     $("#invite_code_input").click(function () {
         $("#copy_content").click();
     })
 
     $("#modal_question_button").click(function () {
         var question = $("#question_input").val().replace(/\s+/g, "");;
         newQuestion = $("#question_select").val().replace(/\s+/g, "");;
         if (newQuestion != question) {
             if (newQuestion.length < 5 && !isEmpty(newQuestion) || newQuestion.length > 16) {
                 toastr.options = {
                     "positionClass": "toast-top-title-center",
                 };
                 toastr.error("找回密码问题格式有误！问题格式：5至16位字符");
                 return false;
             }
             $.ajax({
                 async: true,
                 url: "/user/update",
                 data: {
                     updateFlag: 5,
                     question: newQuestion
                 },
                 dataType: "json",
                 success: function (data) {
                     if (data.status == 200) {
                         toastr.options = {
                             "positionClass": "toast-top-title-center",
                         };
                         toastr.info("修改成功");
                         getCurrentUser();
                     } else {
                         toastr.options = {
                             "positionClass": "toast-top-title-center",
                         };
                         toastr.error(data.msg);
                     }
 
                 },
                 error: function (data) {
                     toastr.options = {
                         "positionClass": "toast-top-title-center",
                     };
                     toastr.error("修改失败");
                 },
                 type: "post"
             });
         }
     })
 })